package com.opentd.gui;

import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.JFrame;

import com.opentd.game.Game;

public class Frame extends JFrame{
	public static Frame instance;

	/**
	 * Constructor for the frame class
	 */
	public Frame(){
		setTitle(Game.TITLE);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setResizable(false);
		pack();

		setSize(new Dimension(600, 600));
		setVisible(true);
	}
	
	/**
	 * The very first method that should get called at the start of the game.
	 * 
	 * Initializes all static variables in the Game class, and
	 * hands execution of the program over to the game loop.
	 */
	public static void startGame(){
		instance = new Frame();
		Game.init();
		instance.init();
	}
	
	/**
	 * Creates all of the components used in the frame.
	 */
	private void init(){
		this.add(Game.panel);
		addMouseListener(Game.mouseListener);
		addMouseMotionListener(Game.mouseMotionListener);
		Game.logicLoop.start();
		Game.paintLoop.start();
	}

}
